home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 4
/
Aminet 4 - November 1994.iso
/
aminet
/
dev
/
gui
/
muibuilderv11.lha
/
muibuilder
/
mb
/
c
/
locale
/
Small_cat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-06
|
7KB
|
229 lines
/****************************************************************
This file was created automatically by `FlexCat V1.0'
Do NOT edit by hand!
****************************************************************/
#ifndef Small_Example_CAT_H
#include "Small_Example_CAT.h"
#endif /* !Small_Example_CAT_H */
#include <string.h>
#ifndef EXEC_MEMORY_H
#include <exec/memory.h>
#endif /* !EXEC_MEMORY_H */
#ifndef LIBRARIES_IFFPARSE_H
#include <libraries/iffparse.h>
#endif /* !LIBRARIES_IFFPARSE_H */
#ifndef CLIB_IFFPARSE_PROTOS_H
#include <clib/iffparse_protos.h>
#endif /* !CLIB_IFFPARSE_PROTOS_H */
#ifndef CLIB_LOCALE_PROTOS_H
#include <clib/locale_protos.h>
#endif /* !CLIB_LOCALE_PROTOS_H */
#ifndef CLIB_DOS_PROTOS_H
#include <clib/dos_protos.h>
#endif /* !DOS_PROTOS_H */
#ifndef CLIB_EXEC_PROTOS_H
#include <clib/exec_protos.h>
#endif /* !EXEC_PROTOS_H */
#ifndef CLIB_UTILITY_PROTOS_H
#include <clib/utility_protos.h>
#endif /* !CLIB_UTILITY_PROTOS_H */
#ifdef AZTEC_C
#ifndef __PRAGMAS_LOCALE_LIB_H
#include <pragmas/locale_lib.h>
#endif /* !PRAGMAS_LOCALE_LIB_H */
#ifndef __PRAGMAS_IFFPARSE_LIB_H
#include <pragmas/iffparse_lib.h>
#endif /* !PRAGMAS_IFFPARSE_LIB_H */
#ifndef __PRAGMAS_DOS_LIB_H
#include <pragmas/dos_lib.h>
#endif /* !PRAGMAS_DOS_LIB_H */
#ifndef __PRAGMAS_EXEC_LIB_H
#include <pragmas/exec_lib.h>
#endif /* !PRAGMAS_EXEC_LIB_H */
#ifndef __PRAGMAS_UTILITY_LIB_H
#include <pragmas/utility_lib.h>
#endif /* !PRAGMAS_UTILITY_LIB_H */
#endif /* AZTEC_C */
static LONG Small_Example_Version = 0;
static const STRPTR Small_Example_BuiltInLanguage = (STRPTR) "english";
struct FC_Type
{ LONG ID;
STRPTR Str;
};
static const struct FC_Type Small_Example_Array [] =
{
MSG_AppDescription, (STRPTR) "Here is a small Example of MUI-Builder",
MSG_WI_smallExample, (STRPTR) "Small Example",
MSG_GR_lists, (STRPTR) "two lists",
MSG_BT_ok, (STRPTR) "_o OK",
MSG_BT_cancel, (STRPTR) "_c Cancel",
};
static struct Catalog *Small_Example_Catalog = NULL;
static struct FC_Type *Small_Example_OwnCatalog = NULL;
static LONG Small_Example_OwnStrings;
static LONG Small_Example_OwnBytes;
void OpenSmall_ExampleCatalog(struct Locale *loc, STRPTR language)
{ LONG tag, tagarg;
extern struct Library *LocaleBase;
extern struct Library *IFFParseBase;
CloseSmall_ExampleCatalog(); /* Not needed if the programmer pairs Open-()
and CloseCatalog() right, but does no harm. */
if (language == NULL)
{ tag = TAG_IGNORE;
}
else
{ tag = OC_Language;
tagarg = (LONG) language;
}
if (LocaleBase != NULL && Small_Example_Catalog == NULL)
{ Small_Example_Catalog = OpenCatalog(loc, (STRPTR) "Small_Example.catalog",
OC_BuiltInLanguage, Small_Example_BuiltInLanguage,
tag, tagarg,
OC_Version, Small_Example_Version,
TAG_DONE);
}
if (LocaleBase == NULL && IFFParseBase != NULL && language != NULL &&
Stricmp(language, Small_Example_BuiltInLanguage) != 0)
{ struct IFFHandle *iffhandle;
char path[128]; /* Enough to hold 4 path items (dos.library 3.0) */
if ((iffhandle = AllocIFF()) != NULL)
{ /* Trying to open the catalog */
strcpy(path, "Catalogs");
AddPart((STRPTR) path, language, sizeof(path));
AddPart((STRPTR) path, (STRPTR) "Small_Example.catalog", sizeof(path));
if ((iffhandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE))
== NULL)
{ strcpy(path, "Locale:Catalogs");
AddPart((STRPTR) path, language, sizeof(path));
AddPart((STRPTR) path, (STRPTR) "Small_Example.catalog", sizeof(path));
iffhandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE);
}
if (iffhandle->iff_Stream)
{ InitIFFasDOS(iffhandle);
if (!OpenIFF(iffhandle, IFFF_READ))
{ if (!PropChunk(iffhandle, MAKE_ID('C','T','L','G'),
MAKE_ID('S','T','R','S')))
{ struct StoredProperty *sp;
int error;
for (;;)
{ if ((error = ParseIFF(iffhandle, IFFPARSE_STEP))
== IFFERR_EOC)
{ continue;
}
if (error != 0)
{ break;
}
if (sp = FindProp(iffhandle, MAKE_ID('C','T','L','G'),
MAKE_ID('S','T','R','S')))
{ LONG *ptr;
LONG BytesToScan, StrLength;
/* First scan: Check the number of strings */
/* Note that this assumes that the strings are padded */
/* to a longword boundary! */
Small_Example_OwnBytes = 0;
Small_Example_OwnStrings = 0;
BytesToScan = sp->sp_Size;
ptr = sp->sp_Data;
while (BytesToScan > 0)
{ ++Small_Example_OwnStrings;
++ptr; /* Skip ID */
StrLength = *ptr+1; /* NUL-Byte! */
Small_Example_OwnBytes += StrLength;
ptr += 1+(StrLength+3)/4; /* Skip Length and String*/
BytesToScan -= 8+((StrLength+3)/4)*4;
}
/* Marginal check: BytesToScan has to be 0! */
if (BytesToScan == 0)
{ char *cptr;
LONG i;
if (Small_Example_OwnCatalog = (struct FC_Type *)
AllocMem(Small_Example_OwnStrings*sizeof(struct FC_Type)+Small_Example_OwnBytes,
MEMF_ANY))
{ /* Second scan: Copy the strings and their ID's */
cptr = (char *) &Small_Example_OwnCatalog[Small_Example_OwnStrings];
BytesToScan = sp->sp_Size;
ptr = sp->sp_Data;
i = 0;
while (BytesToScan > 0)
{ Small_Example_OwnCatalog[i].ID = *(ptr++);
Small_Example_OwnCatalog[i].Str = (STRPTR) cptr;
StrLength = *ptr+1; /* NUL-Byte! */
ptr++;
strncpy(cptr, (char *) ptr, StrLength);
/* Not more, not less bytes! */
cptr+=StrLength;
ptr += (StrLength+3)/4;
BytesToScan -= 8+((StrLength+3)/4)*4;
++i;
}
break;
}
}
}
}
}
CloseIFF(iffhandle);
}
Close(iffhandle->iff_Stream);
}
FreeIFF(iffhandle);
}
}
}
void CloseSmall_ExampleCatalog(void)
{ if (LocaleBase != NULL)
{ CloseCatalog(Small_Example_Catalog);
}
Small_Example_Catalog = NULL;
if (Small_Example_OwnCatalog != NULL)
{ FreeMem(Small_Example_OwnCatalog,
Small_Example_OwnStrings*sizeof(struct FC_Type)+Small_Example_OwnBytes);
Small_Example_OwnCatalog = NULL;
}
}
STRPTR GetSmall_ExampleString(LONG strnum)
{ STRPTR defaultstr = NULL;
LONG i;
for (i = 0; i < sizeof(Small_Example_Array)/sizeof(struct FC_Type); i++)
{ if (Small_Example_Array[i].ID == strnum)
{ defaultstr = Small_Example_Array[i].Str;
break;
}
}
if (Small_Example_Catalog == NULL)
{ if (Small_Example_OwnCatalog != NULL)
{ for (i = 0; i < Small_Example_OwnStrings; i++)
{ if (Small_Example_OwnCatalog[i].ID == strnum)
{ return(Small_Example_OwnCatalog[i].Str);
}
}
}
return(defaultstr);
}
return(GetCatalogStr(Small_Example_Catalog, strnum, defaultstr));
}